package logic

import (
	"context"
	"doc/doc_srv/pb"

	"doc/api/internal/svc"
	"doc/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type DocListLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewDocListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DocListLogic {
	return &DocListLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *DocListLogic) DocList(req *types.DocListRequest) (resp *types.ApiResponse, err error) {
	// todo: add your logic here and delete this line
	list, err := l.svcCtx.DocSrv.DocList(l.ctx, &pb.DocListReq{})
	if err != nil {
		return &types.ApiResponse{
			Code: -1,
			Msg:  "医生列表查询失败",
			Data: nil,
		}, nil
	}
	return &types.ApiResponse{
		Code: 200,
		Msg:  "医生列表查询成功",
		Data: map[string]interface{}{
			"DocList": list,
		},
	}, nil
}
